﻿using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace EmployeeLeaveSystem.Server.Migrations
{
    /// <inheritdoc />
    public partial class Init11 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_AddWOMs_StaffInfos_StaffId",
                table: "AddWOMs");

            migrationBuilder.CreateTable(
                name: "SalaryInfos",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Year = table.Column<int>(type: "int", nullable: false),
                    Month = table.Column<int>(type: "int", nullable: false),
                    StaffId = table.Column<int>(type: "int", nullable: false),
                    BaseSalary = table.Column<double>(type: "float", nullable: false),
                    AddLiveSalary = table.Column<double>(type: "float", nullable: false),
                    CutOffSalary = table.Column<double>(type: "float", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SalaryInfos", x => x.Id);
                    table.ForeignKey(
                        name: "FK_SalaryInfos_StaffInfos_StaffId",
                        column: x => x.StaffId,
                        principalTable: "StaffInfos",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_SalaryInfos_StaffId",
                table: "SalaryInfos",
                column: "StaffId");

            migrationBuilder.AddForeignKey(
                name: "FK_AddWOMs_StaffInfos_StaffId",
                table: "AddWOMs",
                column: "StaffId",
                principalTable: "StaffInfos",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_AddWOMs_StaffInfos_StaffId",
                table: "AddWOMs");

            migrationBuilder.DropTable(
                name: "SalaryInfos");

            migrationBuilder.AddForeignKey(
                name: "FK_AddWOMs_StaffInfos_StaffId",
                table: "AddWOMs",
                column: "StaffId",
                principalTable: "StaffInfos",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
    }
}
